<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:isc="http://extension-functions.intersystems.com" xmlns:hl7="urn:hl7-org:v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:exsl="http://exslt.org/common" exclude-result-prefixes="isc hl7 xsi exsl">

		
	<!-- 个人史/社会史章节 -->
	<xsl:template match="*" mode="HCCSocialHistorySection">
		<xsl:apply-templates select="$sectionRootPath[hl7:code/@code=$hcc_SocialHistory]" mode="HCCSocialHistoryEntry">
		</xsl:apply-templates>
	</xsl:template>
	<!-- 个人史/社会史章节条目 -->
	<xsl:template match="*" mode="HCCSocialHistoryEntry">
		<xsl:apply-templates select="hl7:entry/hl7:observation" mode="HCCSocialDeterminant">
			<xsl:with-param name="sectionType" select="'SH'"/>
		</xsl:apply-templates>
	</xsl:template>	

	
	<!--通用个人史/社会史条目输出模板-->
	<xsl:template match="*" mode="HCCSocialDeterminant">
		<xsl:param name = "sectionType" />
		<SocialDeterminant>
		<EncounterNumber><xsl:value-of select="$encompassingEncounterID"/></EncounterNumber>
		<ExternalId><xsl:value-of select="concat($hccDocNo,'-',$sectionType,'-',position())"/></ExternalId>
		<SocialDeterminantCode>
			<Code><xsl:value-of select="hl7:code/@code"/></Code>
			<Description><xsl:value-of select="hl7:code/@displayName"/></Description>
		</SocialDeterminantCode>
		<Comments><xsl:value-of select="hl7:value"/></Comments>
		<SocialDeterminantValueText><xsl:value-of select="hl7:value"/></SocialDeterminantValueText>
		</SocialDeterminant>		
	</xsl:template>
	
</xsl:stylesheet>
